home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
176-200
/
scopedisk193
/
arexx
/
arexx
< prev
next >
Wrap
Text File
|
1995-03-19
|
8KB
|
150 lines
ARexx
An Introduction by Mathias Sagartz
From the New Mexico Commodore User Group Newsletter - DIMensions
The ARexx programming language is about the biggest buzz word being
kicked around in the Amiga community today.
Almost every piece of new software, except for games, advertises that it
has an "Arexx port", and Commodore is reported to be including ARexx
with the 2.0 version of the operating system. It appears that at long
last, we will have a tool that will help us realize the full potential
of the multi-tasking operating system incorporated in our Amigas.
Really neat stuff. Everybody seems to agree on that ... But what is it?
The ARexx articles I've read in the Amiga press have not done well at
answering that question -- and others -- for me. They all seemed to be
written for professional programmers, folks with at least 5 years of
experience.
This article is for the rest of us. It is an attempt to provide some
perspective for our members who have no background or experience with
ARexx. I also hope to give those of you with an adventuresome spirit a
little nudge toward trying your hand with ARexx.
ARexx is a full-fledged computer language, just like Modula2, Fortran, C
and BASIC. It's a modern language, invented in 1985 by an IBM research
scientist. Like BASIC, it is an interpreted language, i.e. there is no
separate compile step needed to run an ARexx program.
To write an ARexx program, you just make an ASCII file of program
statements with your favorite text editor or word processor. The
program is run by invoking the interpreter, which marches through the
file and executes the statements sequentially.
If you are accustomed to programming in other languages, you'll probably
find ARexx pretty "free form".
Some features that are a bit unusual are:
Typeless data:
Unlike most other languages, you don't have to classify your variables
as integer, floating point or string, etc. A variable can have a value
of 7.3 at one point in the program and be redefined later as "Randolph".
Variable Arithmetic Precision:
The number of significant digits kept for basic arithmetic operations
(add, subtract, multiply or divide) can be whatever you want them to be.
If you'd like to keep 87 significant digits, you may do so. Just don't
expect the program to run very quickly.
Built-in Functions for Parsing Input:
Probably the most important feature of ARexx is the parsing capability
built into many of its commands. It is a simple matter to read a line
from a file and store every\thing on that line up to the first ":" in
one variable, then store everything between the ":" and a "/" in a
second variable, and finally set a third variable equal to whatever is
left over. You then can use a function to examine each of these
variables and determine the type of information (numeric, binary,
alphabetic, etc.) that is stored in them.
Handling of commands for other applications:
During the execution of an ARexx program, if a line of code cannot be
identified as an Arexx instruction, then that instruction is sent
automatically to a "host address". This means the command is passed as
input to another, predesignated task that is also running at that time.
All that is well and good, but I did say this was not going to be one of
those articles written specifically for programmers, didn't I? For most
of us, the great strength of ARexx is its ability to communicate easily
with other tasks running concurrently on the system. This communication
takes place through magical things called message ports. The nice thing
about these ports is that in order to use them, you don't need to know
very much about them. When a program that has an ARexx port begins
execution, it opens a port that can be used to transfer information
between itself and an ARexx program.
ARexx constantly monitors the system and keeps a list of all the ports
that are open and available for use. For the curious, there is an ARexx
command that displays a list of these ports on the screen. The names of
the ports usually are chosen so that they can be identified easily with
their parent program.
Let's assume ARexx is being used to write "macro" commands for an
application. (Simply put, a macro command is a sequence of commands for
an application that are grouped together and stored as an entity.) To
perform this sequence of commands, the user need not type each command
separately. All he/she has to do is to issue one command that invokes
he macro, and the sequence of commands is executed automatically.
What makes ARexx useful for writing macros is that an ARexx macro need
not be dumb. An ARexx macro normally is executed one command at a time.
The first command is sent to the host, and the macro then waits for the
host to send back a message that indicates whether the command was
executed successfully. The host also can pass back information about
the results of the command, and logic programmed into the ARexx macro
can adjust what the macro sends back to the host as the next command.
For host programs that get their user input from command lines, the
ARexx macro will look very much like a sequence of these commands,
perhaps with some logic-type statements mixed in to provide the smarts
for the macro. However, many host programs get input from information
typed into requestor boxes or mouse selection of menu items. The
authors of these programs must provide a set of "command descriptions"
that specify the syntax for the messages ARexx can send to the host to
provide equivalent input.
Another element of flexibility provided by an ARexx program is that it
is not restricted to communicating with only one host program. An
"address" statement can direct a command to any of the available message
ports. By using several different ports, ARexx can take information
from one host, edit it, modify it, and send the result as input to a
different host. In effect, it can become a master controller that
unifies different host programs so they can work together. As you can
see, ARexx applications can get as sophisticated as you choose to make
them.
The user's manual furnished with ARexx is complete, but it is very
condensed. It is written well, but it definitely is not intended for
the novice programmer. For those who are interested, there is a good
beginner-level book entitled "Modern Programming Using Rexx" by O'Hara
and Gomberg (Prentice-Hall). The authors presume their audience will be
programming on an IBM mainframe, but very little is machine specific.
Comparing this book with the user's manual shows that ARexx indeed is a
complete implementation of the Rexx programming language.
Commodore itself also should be a source for ARexx information. The
manufacturer certainly will include some sort of basic-level ARexx
reference with the 2.0 operating system update.
Time will tell. As an aid to those who want to try their hands with
ARexx, I've included a copy of a short program that can be used to try
ARexx commands. The Rexxtry program was copied out of the O'Hara and
Gomberg reference. Essentially, it will let you do what the immediate
mode does for AmigaBasic. Enter a line of code, and when you hit
return, the line will be executed.
Enjoy!
/* program to execute a single line of Rexx code from O'Hara and Gomberg */
say "Rexxtry allow you to interactively execute Rexx instructions."
say "Each instruction string is executed when you press enter."
say "To end, enter exit."
do forever /* the exit instruction will terminate the loop */
say "Rexxtry"
parse pull @line@
interpret @line@
end